//
//  ViewController.m
//  10603
//
//  Created by student on 16/3/5.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

//定义为当前屏幕的宽
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
//定义为当前屏幕的高
#define kScreenHeight [UIScreen mainScreen].bounds.size.height

//当我自己设置的main.storyboard的尺寸为6的时候(即width 为375, height 为667)
//竖屏的时候
#define W(x) (x * kScreenWidth / 320.0)
#define H(y) (y * kScreenHeight / 568.0)
//横屏的时候
#define WR(y) (y * kScreenHeight / 320.0)
#define HR(x) (x * kScreenWidth / 568.0)

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *label1;
@property (weak, nonatomic) IBOutlet UILabel *label2;
@property (weak, nonatomic) IBOutlet UILabel *label3;
@property (weak, nonatomic) IBOutlet UILabel *label4;
@property (weak, nonatomic) IBOutlet UILabel *label5;
@property (weak, nonatomic) IBOutlet UILabel *label6;

@end

@implementation ViewController

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||  toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        //手机处于水平位置
        self.label1.frame = CGRectMake(WR(20), HR(20), WR(100), HR(100));
        self.label2.frame = CGRectMake(WR(20), HR(200), WR(100), HR(100));
        self.label3.frame = CGRectMake(WR(233), HR(20), WR(100), HR(100));
        self.label4.frame = CGRectMake(WR(233), HR(200), WR(100), HR(100));
        self.label5.frame = CGRectMake(WR(448), HR(20), WR(100), HR(100));
        self.label6.frame = CGRectMake(WR(448), HR(200), WR(100), HR(100));
    }
    else{
        //手机处于垂直位置
        self.label1.frame = CGRectMake(W(20), H(20), W(100), H(100));
        self.label2.frame = CGRectMake(W(200), H(20), W(100), H(100));
        self.label3.frame = CGRectMake(W(20), H(233), W(100), H(100));
        self.label4.frame = CGRectMake(W(200), H(233), W(100), H(100));
        self.label5.frame = CGRectMake(W(20), H(448), W(100), H(100));
        self.label6.frame = CGRectMake(W(200), H(448), W(100), H(100));
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
